// string number boolean null undefined symbol bigint object
let str = "hello";

// any 类型
let a: any = "aaa";
let aa = null;

// 字面量类型
const b = "hello";
const c = null;

let d: "world";
d = "world"
// d = "aaa"; // 报错

// 联合类型
let v1: string | number | boolean | undefined = undefined;
v1 = "aaa";
v1 = 123;
v1 = true
// v1 = null; // 报错

let v2: "男" | "女";
v2 = "男";

let v3: "UP" | "DOWN" | "LEFT" | "RIGHT" = "UP";
v3 = "LEFT";
v3 = "RIGHT";

// 数组类型
// 数组类型可以有两种表示方式
// 类型[]
// Array<类型>
const arr1: string[] = ["a", "b", "c"];
const arr2 = [1, 2, 3, 4, 5];
const arr3: Array<number> = [1, 2, 3, 4, 5];
const arr4: Array<string> = ["a", "b", "c"];

// 空数组赋值，在strict严格检查下，默认是any类型
// 但是这个和其他类型检查配置相关noImplicitAny
const arr5 = [];
arr5.push(1);
arr5.push("abc");

// 数组也能用联合类型
const arr6: (string | number)[] = ["a", 1, "b", 2];
const arr7: Array<string | number> = ["a", 1, "b", 2];
// 注意和下面的写法进行区分
const arr8: string[] | number[] = [1,2,3,4];
const arr9: Array<string> | Array<number> = ["a", "b", "c"];

// 元组类型
const tuple1: [string, number] = ["a", 1];
const tuple2: [number, number, number] = [1, 2, 3];

// 使用场景：坐标
// let position:number[] = [39.5436, 117.2312];
let position: [number, number] = [39.5436, 117.2312];

// 一个容易混淆的赋值情况
let value = [];
let tuple3: [] = []; // 空元祖
